package gov.fema.hazus.bdc.client;

import gov.fema.hazus.bdc.client.login.Login;
import gov.fema.hazus.bdc.client.settings.Settings;
import gov.fema.hazus.bdc.client.ui.BuildingEditor;
import gov.fema.hazus.bdc.client.ui.BuildingList;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;


public class UIController implements UIControllerInterface {

    private static UIController singleton;
    public static UIController get()
    {
        if( singleton == null )
        {
            singleton = new UIController();
        }
        return singleton;
    }
    
    public UIController()
    {
    	
    }
    
    /*
     * After successful login, load the MainUI and hide
     * the Login user interface
     * @see gov.fema.riskmap.assessment.hazus.incast.common.client.ui.UIControllerInterface#login()
     */
	public void login() {
		
		/* moved to InCAST
		Login login = Login.get();
        if( login != null && login.isAttached())
        {
            login.setVisible(false);
        }
        MainUI.get().setVisible(true);
		*/
	}

	public void reload() {
		// TODO Auto-generated method stub
		
	}

	public void actionAddBuilding() {
		// TODO Auto-generated method stub
		/*
        Building building = new Building();
        UserEditor.get().updateBuilding(building);
        showBuildingEditor();
        */
	}

	public void actionGetBuildings() {
		// TODO Auto-generated method stub
		/*
        if( this.buildings == null )
        {
            GWT.log("fetching buildings from proxy", null);
            SearchServiceProxy.get().getBuildings(buildingMapHandler);
        }
        else
        {
            GWT.log("already have buildings from proxy, just show map", null);
            showBuildingMap();
        }	
        */	
	}

	public void getBuildings()
	{
        BuildingList.get().setSearchFlag(false);
        BuildingList.get().resetAndGetBuildings();	
	}
	
	public void showBuildingList() {

        Window.enableScrolling(true);
        
        //map.setVisible(false);
        BuildingEditor.get().setVisible(false);
        Settings.get().setVisible(false);
        BuildingList.get().setVisible(true);
        GWT.log("UIController.showBuildingList", null);
        MainUI.get().onWindowResized(Window.getClientWidth(), Window.getClientHeight());        
	}

	public void logout() {
		// TODO Auto-generated method stub
		
	}

	public void showBuildingMap() {
		// TODO Auto-generated method stub
		
	}

	public void displayListView() {
		// TODO Auto-generated method stub
		
	}

	public void reloadApplication() {
		// TODO Auto-generated method stub
		
	}

	public void showSettings() {
		
	}

	public void showLoginPage() {
		MainUI.get().setVisible(false);
		Login.get().setVisible(true);
	}

	public void restoreTitle() {
		// TODO Auto-generated method stub
		
	}

	public void setSearchBorder(boolean b) {
		// TODO Auto-generated method stub
		
	}

	public void showBuildingEditor() {
		BuildingEditor.get().setVisible(true);
	}

}
